import { Point } from "./Point.js";

/**
 * 方块形态（旋转改变形态）
 */
export class Form {
    #points: Point[];
    #width: number;
    #height: number;

    constructor(points: number[][]) {
        let right: number = 0;
        let bottom: number = 0;

        this.#points = points.map(p => {
            const point = new Point(p[0], p[1]);
            right = Math.max(right, point.x);
            bottom = Math.max(bottom, point.y);
            return point;
        });

        this.#width = right + 1;
        this.#height = bottom + 1;
    }

    get points(): Readonly<Point[]> {
        return [...this.#points];
    }

    get width(): number {
        return this.#width;
    }

    get height(): number {
        return this.#height;
    }
}
